using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Tests.Win32.SafeHandles.SafeTokenHandle
{
    [TestClass]
    public class WhenReleasingHandle
    {
        [TestMethod]
        public void ShouldNotThrowOnInvalidHandle()
        {
            using(Framework.Win32.SafeHandles.SafeTokenHandle handle = new Framework.Win32.SafeHandles.SafeTokenHandle())
            {
                MethodInfo releaseHandleInfo = handle.GetType().GetMethod("ReleaseHandle", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
                bool actual = (bool) releaseHandleInfo.Invoke(handle, null);

                Assert.IsTrue(actual);
            }
        }
    }
}